package com.dao;

import com.pojo.Dep;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DepDAO extends JpaRepository<Dep,Integer> {

     //hql(jpql,) 1.表名写类名  2.字段名写属性名  3.不能用select *
     //@Query("from Dep where depId=?0 and depName=?1")
     @Query(value = "select * from Dep where depId=?1 or depName=?2",nativeQuery = true)
     List<Dep> getAll(Integer depId, String depName);

     List<Dep> findByDepIdOrDepName(Integer depId,String depName);


     @Query(value = "select *  from Dep d where (?1 is null or d.depId=?1) and  (?2 is null or d.depName like ?2)",nativeQuery = true)
     Page<Dep> search(Integer depId, String depName, Pageable  pageable);
}
